Controlling crack propagation in brittle materials through residual stress